package com.hunlian.makelove.adapter;

import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import java.util.List;

/**
 * Created by zealjiang on 2016/12/23 14:43.
 * Email: zealjiang@126.com
 */

public abstract class ModelAdapter<T> extends BaseAdapter {

    private List<T> modeList;
    @Override
    public int getCount() {
        if(modeList!=null && modeList.size()>0){
            return modeList.size();
        }else
            return 0;
    }
    public T getModel(int position) {
        return (T) getItem(position);
    }

    @Override
    public Object getItem(int position) {
        if (modeList != null){
            return modeList.get(position);
        }else
            return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public abstract View getView(int position, View convertView, ViewGroup parent);

    public void setList(List<T> list){
        this.modeList = list;
    }


    public List<T> getModeList() {
        return modeList;
    }
}